<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Clojure documentation browser</title><style>
.library
{
  padding: 0.5em 0 0 0 
}
.all-libs-toggle,.library-contents-toggle
{
 font-size: small;
}
.all-libs-toggle a,.library-contents-toggle a
{
 color: white
}
.library-member-doc-whitespace
{
 white-space: pre
}
.library-member-source-toggle
{
  font-size: small;
  margin-top: 0.5em
}
.library-member-source
{
  display: none;
  border-left: solid lightblue 
}
.library-member-docs
{
  font-family:monospace
}
.library-member-arglists
{
  font-family: monospace
}
.library-member-type
{
  font-weight: bold; 
  font-size: small;
  font-style: italic;
  color: darkred
}
.lib-links
{
  margin: 0 0 1em 0
}

.lib-link-header
{
  color: white;
  background: darkgreen;
  width: 100%
}

.library-name 
{ 
  color: white;
  background: darkblue;
  width: 100%
}

.missing-library
{
  color: darkred; 
  margin: 0 0 1em 0 
}

.library-members
{
  list-style: none
}

.library-member-name
{
  font-weight: bold;
  font-size: 105%
}</style><script language="JavaScript" type="text/javascript"> // <![CDATA[

function getElem(id)
{
  if( document.getElementById )
  {
    return document.getElementById( id )
  }
  else if ( document.all )
  {
    return eval( 'document.all.' + id )
  }
  else
    return false;
}

function setDisplayStyle(id,displayStyle)
{
  var elem = getElem (id)
  if (elem)
  {
    elem.style.display = displayStyle
  }

}

function setLinkToggleText (id, text)
{
 var elem = getElem (id)
 if (elem)
 {
   elem.innerHTML = text
 }
}

function collapse(id)
{
  setDisplayStyle (id, 'none')
}

function expand (id)
{
  setDisplayStyle (id, 'block')
}

function toggleSource( id )
{
  toggle(id, 'linkto-' + id, 'Hide Source', 'Show Source')
}

function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
{
  var elem = getElem (targetid)
  var link = getElem (linkid)

  if (elem && link)
  {
    var isOpen = false
    if (elem.style.display == '')
    {
      isOpen = link.innerHTML == textWhenOpen
    }
    else if( elem.style.display == 'block' )
    {
      isOpen = true
    }
    
    if (isOpen)
    {
      elem.style.display = 'none'
      link.innerHTML = textWhenClosed
    }
    else
    {
      elem.style.display = 'block'
      link.innerHTML = textWhenOpen
    }
  }
}

      //]]>
</script><script language="JavaScript" type="text/javascript">// <![CDATA[!
function expandAllNamespaces()
{
expand(&apos;library-contents-appli.hadesWindow&apos;);
setLinkToggleText(&apos;library-contents-toggle-appli.hadesWindow&apos;, &apos;-&apos;);

}function collapseAllNamespaces()
{
collapse(&apos;library-contents-appli.hadesWindow&apos;);
setLinkToggleText(&apos;library-contents-toggle-appli.hadesWindow&apos;, &apos;+&apos;);

}
// ]]></script></head><body><div class="lib-links"><div class="lib-link-header">Namespaces<span class="all-libs-toggle"> [ <a href="javascript:expandAllNamespaces()">Expand All</a> ] [ <a href="javascript:collapseAllNamespaces()">Collapse All</a> ]</span></div><a class="lib-link" href="#library-appli.hadesWindow">appli.hadesWindow</a></div><div class="library"><a name="library-appli.hadesWindow"/><div class="library-name"><span class="library-contents-toggle">[ <a id="library-contents-toggle-appli.hadesWindow" href="javascript:toggle(&apos;library-contents-appli.hadesWindow&apos;, &apos;library-contents-toggle-appli.hadesWindow&apos;, &apos;-&apos;, &apos;+&apos;)">-</a> ] </span>appli.hadesWindow</div><div class="library-contents" id="library-contents-appli.hadesWindow"><div class="library-member-links"><a class="lib-member-link" href="#member-appli.hadesWindow--main">-main</a> <a class="lib-member-link" href="#member-appli.hadesWindow-change-Foreground-table">change-Foreground-table</a> <a class="lib-member-link" href="#member-appli.hadesWindow-convertToMap">convertToMap</a> <a class="lib-member-link" href="#member-appli.hadesWindow-convertToVec">convertToVec</a> <a class="lib-member-link" href="#member-appli.hadesWindow-count-records">count-records</a> <a class="lib-member-link" href="#member-appli.hadesWindow-fill-JTable">fill-JTable</a> <a class="lib-member-link" href="#member-appli.hadesWindow-fill-JTable-DefaultModel">fill-JTable-DefaultModel</a> <a class="lib-member-link" href="#member-appli.hadesWindow-filter-records">filter-records</a> <a class="lib-member-link" href="#member-appli.hadesWindow-filter-records-search">filter-records-search</a> <a class="lib-member-link" href="#member-appli.hadesWindow-get-position-in-Db">get-position-in-Db</a> <a class="lib-member-link" href="#member-appli.hadesWindow-get-record-table">get-record-table</a> <a class="lib-member-link" href="#member-appli.hadesWindow-get-records-map">get-records-map</a> <a class="lib-member-link" href="#member-appli.hadesWindow-get-records-vector">get-records-vector</a> <a class="lib-member-link" href="#member-appli.hadesWindow-window">window</a> <a class="lib-member-link" href="#member-appli.hadesWindow-windowClient">windowClient</a> <a class="lib-member-link" href="#member-appli.hadesWindow-windowSearchResult">windowSearchResult</a></div><ol class="library-members"><li class="library-member"><a name="member-appli.hadesWindow--main"/><dl class="library-member-table"><dt class="library-member-name">-main</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([&amp; args])</span></div><div class="library-member-docs"/><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow--main&apos;)" id="linkto-membersource-appli.hadesWindow--main">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow--main"><pre>(defn -main
	[&amp; args]
		(if (= (first args) &quot;alone&quot;)
			(window &quot;Hades Booking System&quot;)
			(if (= (first args) &quot;server&quot;)
				(serverLoop)
				(if (= (first args) &quot;client&quot;)
					(let [
						socketClient (Socket. (last args) *port*)
						output			(DataOutputStream. (.getOutputStream socketClient))
						input			(DataInputStream. (.getInputStream socketClient))
						serverAdd		(.readUTF input)
						]
						(println (str &quot;Server Address: &quot; serverAdd))
						(windowClient &quot;Hades Booking System Client&quot; socketClient input output serverAdd)
					)
					(println &quot;Select: alone, server, client &quot;)
				)
			)
		)
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-change-Foreground-table"/><dl class="library-member-table"><dt class="library-member-name">change-Foreground-table</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([t])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Change the Jtable Foreground Color</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-change-Foreground-table&apos;)" id="linkto-membersource-appli.hadesWindow-change-Foreground-table">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-change-Foreground-table"><pre>(defn change-Foreground-table 
 &quot;Change the Jtable Foreground Color&quot;   
    [t]
 
	(.setDefaultRenderer t Object (proxy [DefaultTableCellRenderer] []
	    (getTableCellRendererComponent [tbl obj isSelected hasFocus row cols]
	      (proxy-super getTableCellRendererComponent tbl obj isSelected hasFocus row cols)
	      
 	       (doto this
 	          (.setForeground  (condp =    (or (= (.getValueAt tbl   row 6 ) &quot;&quot;) (= (.getValueAt tbl   row 6 ) &quot; &quot;))                                   
                            true (new Color 0x0000FF) ; row without owner 
                            false ( new Color  0xFF1493); row with owner 
                            Color/white))       
          )
	   )
	  )
	 )
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-convertToMap"/><dl class="library-member-table"><dt class="library-member-name">convertToMap</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([list])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Converts a list into a Map, to be able to pass it as parameter in the fill-JTable method.</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-convertToMap&apos;)" id="linkto-membersource-appli.hadesWindow-convertToMap">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-convertToMap"><pre>(defn convertToMap
	&quot;Converts a list into a Map, to be able to pass it as parameter in the fill-JTable method.&quot;
	[list]
	{:records (vec list)})</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-convertToVec"/><dl class="library-member-table"><dt class="library-member-name">convertToVec</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([list])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Converts a list into a Vec, to be able to pass it as parameter in the fill-JTable method.</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-convertToVec&apos;)" id="linkto-membersource-appli.hadesWindow-convertToVec">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-convertToVec"><pre>(defn convertToVec
	&quot;Converts a list into a Vec, to be able to pass it as parameter in the fill-JTable method.&quot;
	[list]
	(vec list))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-count-records"/><dl class="library-member-table"><dt class="library-member-name">count-records</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([vect])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Counts the number of total records from the vector received as parameter.</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-count-records&apos;)" id="linkto-membersource-appli.hadesWindow-count-records">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-count-records"><pre>(defn count-records 
	&quot;Counts the number of total records from the vector received as parameter.&quot;
	[vect]
	(count vect))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-fill-JTable"/><dl class="library-member-table"><dt class="library-member-name">fill-JTable</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([dbRecords read-Db])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Fills the JTable with the map sent as parameter transformed from the vector of those records. Receives two parameters: map of the records to fill the table and the lecture of the Data Base File.</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-fill-JTable&apos;)" id="linkto-membersource-appli.hadesWindow-fill-JTable">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-fill-JTable"><pre>(defn fill-JTable
	&quot;Fills the JTable with the map sent as parameter transformed from the vector of those records. Receives two parameters: map of the records to fill the table and the lecture of the Data Base File.&quot;
	[dbRecords read-Db]
	(proxy [AbstractTableModel] [] 
		  	(getRowCount [] (count (get dbRecords :records))) 
			  (getColumnCount [] (get read-Db :num-fields))
			  (isCellEditable  [row col] true)
  			(getColumnName [col]                            
				   (.toUpperCase (str (first (nth (get read-Db :fields) col)))))
   			(getValueAt [row col] (get (nth (get dbRecords :records) row) 
				    (keyword (str (first (nth (get read-Db :fields) col))))))
	)
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-fill-JTable-DefaultModel"/><dl class="library-member-table"><dt class="library-member-name">fill-JTable-DefaultModel</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([table defModel get-row get-column get-value])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Fills the JTable with the database elements.Receives five parameters: table defined, the model of the table, row position, column position, value</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-fill-JTable-DefaultModel&apos;)" id="linkto-membersource-appli.hadesWindow-fill-JTable-DefaultModel">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-fill-JTable-DefaultModel"><pre>(defn fill-JTable-DefaultModel
	&quot;Fills the JTable with the database elements.Receives five parameters: table defined, the model of the table, row position, column position, value&quot;
	[table defModel get-row get-column get-value]
	
	(dorun (for [i (range 0 (.getColumnCount table))]
	(
		.addColumn defModel (.getColumnName table i)
	 ))) ;end dorun columns
	
	(dorun (for [j (range 0 (.getRowCount table))]
	(
		.addRow defModel (to-array [(.getValueAt table j 0) (.getValueAt table j 1) (.getValueAt table j 2) (.getValueAt table j 3) (.getValueAt table j 4) (.getValueAt table j 5) (.getValueAt table j 6)])
	 ))) ;end dorun rows
	
	  (.setModel table defModel)
	 
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-filter-records"/><dl class="library-member-table"><dt class="library-member-name">filter-records</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file-records])</span></div><div class="library-member-docs"><div class="library-member-doc-line"><span class="library-member-doc-whitespace"> </span></div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-filter-records&apos;)" id="linkto-membersource-appli.hadesWindow-filter-records">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-filter-records"><pre>(defn filter-records
	&quot;&quot; 
	[file-records] 
	(filter #(= (:deleted %) false) ; primero veo si no esta borrado	 		
			file-records
	)
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-filter-records-search"/><dl class="library-member-table"><dt class="library-member-name">filter-records-search</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([search-word file-records word-combox])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Filters the records by location with three parameters: the search word, the DB file and which kind of search word it is(name or location). Returns a vector</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-filter-records-search&apos;)" id="linkto-membersource-appli.hadesWindow-filter-records-search">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-filter-records-search"><pre>(defn filter-records-search 
	&quot;Filters the records by location with three parameters: the search word, the DB file and which kind of search word it is(name or location). Returns a vector&quot;
	[search-word file-records word-combox ] 
	(filter #(and 
	 		(= (:deleted %) false) ; primero veo si no esta borrado
	 		(= (.toLowerCase (str ((keyword word-combox) %))) (.toLowerCase (str search-word))) ; luego lo busco las concidencias con la word-combox
	 		) 
			file-records
	)
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-get-position-in-Db"/><dl class="library-member-table"><dt class="library-member-name">get-position-in-Db</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([numOfRows file-records record pos])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Obtain the real position in the database of the record</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-get-position-in-Db&apos;)" id="linkto-membersource-appli.hadesWindow-get-position-in-Db">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-get-position-in-Db"><pre>(defn get-position-in-Db 
 &quot;Obtain the real position in the database of the record&quot;
  [numOfRows file-records record pos]
  (loop [i 0]
		(when (&lt; i numOfRows)
			(if (= (= (file-records i) record) true) (reset! pos i))
			(recur (inc i)))) 
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-get-record-table"/><dl class="library-member-table"><dt class="library-member-name">get-record-table</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([numOfRow tbl])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Get selected row values and returns as a map </div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-get-record-table&apos;)" id="linkto-membersource-appli.hadesWindow-get-record-table">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-get-record-table"><pre>(defn get-record-table 
 &quot;Get selected row values and returns as a map &quot; 
  [numOfRow tbl]
     (if (= (&gt; numOfRow -1) true)
       {:name     (.getValueAt tbl numOfRow 0)
        :location (.getValueAt tbl numOfRow 1)  
        :size     (.getValueAt tbl numOfRow 2)
        :smoking  (.getValueAt tbl numOfRow 3)
        :rate     (.getValueAt tbl numOfRow 4)
        :date     (.getValueAt tbl numOfRow 5)
        :owner    (.getValueAt tbl numOfRow 6)
        :deleted false})
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-get-records-map"/><dl class="library-member-table"><dt class="library-member-name">get-records-map</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([lis])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Gets all the records from Data Base file, returns a map with the records.</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-get-records-map&apos;)" id="linkto-membersource-appli.hadesWindow-get-records-map">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-get-records-map"><pre>(defn get-records-map 
	&quot;Gets all the records from Data Base file, returns a map with the records.&quot;
	[lis]
	 ( convertToMap lis))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-get-records-vector"/><dl class="library-member-table"><dt class="library-member-name">get-records-vector</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Gets all the records from Data Base file, returns a vector with the records.</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-get-records-vector&apos;)" id="linkto-membersource-appli.hadesWindow-get-records-vector">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-get-records-vector"><pre>(defn get-records-vector
	&quot;Gets all the records from Data Base file, returns a vector with the records.&quot;
	[file]
	(vec(for [n (file :records)] n)))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-window"/><dl class="library-member-table"><dt class="library-member-name">window</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([title])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Displays a simple GUI window using the Swing API. The main Window of Hades Booking System Project. Receives one paremeter: title name of the application.</div><div class="library-member-doc-line">   This is where the Interface is painted and manipulated so the main actions take place, adding handlers and listeners. </div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-window&apos;)" id="linkto-membersource-appli.hadesWindow-window">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-window"><pre>(defn window
  &quot;Displays a simple GUI window using the Swing API. The main Window of Hades Booking System Project. Receives one paremeter: title name of the application....&quot;
  [title]
  (let [frame     		(JFrame. title)
        db        		(atom &quot;db-1x2.db&quot; ) 
 	    read-Db   		(read-bin-file @db )
        label     		(JLabel. &quot;Search: &quot; )
        imagelogo 		(ImageIcon. &quot;Images/logohade.png&quot;)
        imagelegend 	(ImageIcon. &quot;Images/leyenda.png&quot;)
        imagelegend2	(ImageIcon. &quot;Images/leyenda2.png&quot;)
        logo        	(JLabel. imagelogo) 
        legend     		(JLabel. imagelegend) 
        legend2     	(JLabel. imagelegend2) 
        txtSearch 		(JTextField. 30 )
        combobox  		(JComboBox. )
        panelTop  		(JPanel. )
        panelRight 		(JPanel. )
        panelBottom 	(JPanel. )
        flowlayout 		(new FlowLayout )
        gridLayout 		(GridLayout. 10 0 5 5)
        btnFind			(JButton. &quot;Find&quot;)
	    btnAdd 			(JButton. &quot;Add&quot;)
		btnDelete		(JButton. &quot;Delete&quot;)
		btnRefresh 		(JButton. &quot;Refresh&quot;) 
		get-column-change        (atom -1)
        get-row-change           (atom -1)
        get-value-at-change      (atom &quot; &quot;)
		get-pos                  (atom -1) 
		get-record-value         (atom &quot; &quot;) 
		recordsVector     (get-records-vector read-Db)
        recordsMap       (get-records-map (filter-records recordsVector) )    
        model  	(fill-JTable recordsMap read-Db)
	    table (JTable. model)
	    defaultModel (DefaultTableModel.)
	    table2 (JTable. defaultModel) 
        scrollTable (JScrollPane. table2)
	    number-records ( count-records recordsVector)
	      
	       
  ;------------Method search---------------------------------------------------------------------
		handlerBtnFind  (proxy [ActionListener][]
			(actionPerformed [event]
	        
				(if (= {:records []} (convertToMap (filter-records-search(.getText txtSearch) recordsVector (.getSelectedItem combobox)))) (JOptionPane/showMessageDialog frame (str &quot;-&quot; (.getText txtSearch) &quot;-&quot; &quot; not found searching by &quot; (.getSelectedItem combobox)) &quot;No results found&quot; JOptionPane/INFORMATION_MESSAGE)
				(windowSearchResult &quot;Search Result&quot; read-Db  (convertToMap (filter-records-search(.getText txtSearch) recordsVector (.getSelectedItem combobox))) )
				)
			)
		)
	;--------------Handler button Add row-------------------------------------------------------				
		handlerBtnAdd  (proxy [ActionListener][]
			(actionPerformed [event]
				(.addRow defaultModel (to-array []))
				(write-empty-row &quot;db-1x2.db&quot; (count-records (get-records-vector (read-bin-file &quot;db-1x2.db&quot;))))
				
				 (.setVisible frame true) 						
				 (.dispose frame) 				  
				 (window &quot;Hades Booking System&quot;)
			)
		)
	;--------------Handler button Deleted--------------------------------------------------------			
handlerBtnDelete (proxy [ActionListener][]
  (actionPerformed [event]
		(let [initialNumber  (.getSelectedRow table2)
				  record	       (get-record-table (.getSelectedRow table2) table2)  
				  pos            (atom -1) 
					]
			     (get-position-in-Db (count-records recordsVector)  recordsVector record pos)
					      (if (= (&gt; @pos -1) true) 		(erase-record &quot;db-1x2.db&quot; @pos) 		) 
			       
					  (dorun (for [i (range (.getSelectedRow table2)(+ (.getSelectedRow table2) (count (.getSelectedRows table2))))]
						          (.removeRow defaultModel initialNumber)
					   ))
					   
							 		 (.setVisible frame true) 						
										(.dispose frame) 				  
										(window &quot;Hades Booking System&quot;)		
				   
			)	
	)
)

handlerRefresh( proxy [ActionListener] []  
 (actionPerformed [event]
    (.setVisible frame true) 						
		(.dispose frame) 				  
		(window &quot;Hades Booking System&quot;)
 )
)				
]
	
	;------------------ Method to fill manually the table ----------------
 	(fill-JTable-DefaultModel table defaultModel get-row-change get-column-change get-value-at-change)
	;---------------------------------------------------------------------
	
	;************************ Create the interface Java***********************************

	
   ;-----------------------PanelTop-------------------------------------
	  (.setIconImage frame (.getImage (ImageIcon. &quot;Images/IconoHades.png&quot;)))
    (.setDefaultCloseOperation frame JFrame/EXIT_ON_CLOSE)
    (.setBackground panelTop (Color. 135 206 235))
    (.setLayout panelTop flowlayout)
    (.setAlignment flowlayout FlowLayout/TRAILING)
    (.add panelTop combobox)
    (.add panelTop txtSearch)
    (.add panelTop label)
    (.addItem combobox &quot;name&quot;)
    (.addItem combobox  &quot;location&quot;)
    (.add panelTop logo)
    (.setComponentOrientation panelTop  ComponentOrientation/RIGHT_TO_LEFT)
    (.add frame panelTop  BorderLayout/NORTH )
    
   ;----------------AddActionListener to the buttons in the frame-----------------------------------
    (.addActionListener btnFind handlerBtnFind)
	(.addActionListener btnAdd handlerBtnAdd)
	(.addActionListener btnDelete handlerBtnDelete)
	(.addActionListener btnRefresh handlerRefresh) 
    (.setPreferredSize panelRight (Dimension. 160 60))
    (.setLayout panelRight gridLayout)
    (.setBackground panelRight (Color. 135 206 235))
         
    (.add panelRight btnFind )
    (.add panelRight btnAdd)
    (.add panelRight btnDelete)
    (.add panelRight btnAdd)
    (.add panelRight btnRefresh)
    (.add panelRight legend)
    (.add panelRight legend2) 
    (.add frame panelRight  BorderLayout/EAST)
     
		
    (.add frame scrollTable)
 
  ;--------------Add Listeners table -------------------------------------
        
  (.addKeyListener table2 
    (proxy [KeyAdapter] []
    
		(keyReleased [event]
			(if (and (not= @get-row-change -1) (not= get-column-change -1) (= (.isEditing table2) true))
				(reset! get-record-value (get-record-table (.getSelectedRow table2) table2))
			)
			
			(if (and (not= @get-row-change -1) (not= @get-column-change -1))  					 
			   (reset! get-value-at-change  (.getValueAt table @get-row-change @get-column-change))
			)         																			   
			
			(if (and (not= @get-value-at-change -1) (not=  @get-row-change -1) (=(.isEditing table2) false) 
			(or (= (.getKeyCode event) VK_ENTER) (= (.getKeyCode event) VK_LEFT) (= (.getKeyCode event) VK_RIGHT)
				(= (.getKeyCode event) VK_UP) (= (.getKeyCode event) VK_DOWN))) 
			
			(let [name     (str (.getValueAt table2 @get-row-change 0))
						location (str (.getValueAt table2 @get-row-change 1))						
						size     (str (.getValueAt table2 @get-row-change 2)) 							 							
						smoking  (str (.getValueAt table2 @get-row-change 3))					
						rate     (str (.getValueAt table2 @get-row-change 4))					
						date     (str (.getValueAt table2 @get-row-change 5))					
						owner    (str (.getValueAt table2 @get-row-change 6))				
						] 
						 (get-position-in-Db (count-records recordsVector)  recordsVector @get-record-value get-pos)
						  (if (&gt; @get-pos -1) 		
							(println @get-pos)
							(write-row-with-values @db @get-pos name location size smoking rate date owner)
						)
						 
								(.repaint table2)
			 ) 
			  (reset! get-value-at-change -1) 
			) 					    
	)
		(keyTyped [event]
			(if (not= (.getEditingRow table2) -1)     (reset!   get-row-change (.getEditingRow table2))) 
			(if (not= (.getEditingColumn table2) -1)  (reset!   get-column-change (.getEditingColumn table2)) )					
		)
	) 
  )
	
	 (.addMouseListener table2 
	  (proxy [MouseListener] [] 
				(mouseClicked [event]) 
				(mouseEntered [event]) 
				(mouseExited  [event]) 
				(mousePressed  [event] 
				  
					(if (not= (.getEditingRow table2) -1)  (reset!   get-row-change (.getEditingRow table2))) 
			    (if (not= (.getEditingColumn table2) -1)  (reset!   get-column-change (.getEditingColumn table2)) )	
			    
			    (if (and (not= @get-row-change -1) (not= @get-column-change -1))  					 
					   (reset! get-record-value (get-record-table (.getSelectedRow table2) table2) ))
	    	) 
		    (mouseReleased [event])
		 ) 
	)
	
	 (change-Foreground-table table2) 
	 
	 ;--------Frame----------------------------------------------------------
	 
    (.pack frame)
    (.setSize frame (Dimension. 900 500))
    (.setVisible frame true))
    ;---------------------------------------------------------------------
    
    
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-windowClient"/><dl class="library-member-table"><dt class="library-member-name">windowClient</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([title socketClient input output serverAdd])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Displays a simple GUI window using the Swing API. The main Window of Hades Booking System Project. Receives one paremeter: title name of the application.</div><div class="library-member-doc-line">   This is where the Interface is painted and manipulated so the main actions take place, adding handlers and listeners. </div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-windowClient&apos;)" id="linkto-membersource-appli.hadesWindow-windowClient">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-windowClient"><pre>(defn windowClient
  &quot;Displays a simple GUI window using the Swing API. The main Window of Hades Booking System Project. Receives one paremeter: title name of the application....&quot;
  [title socketClient input output serverAdd]
  (let [frame     		(JFrame. title)
        ;db        		(atom &quot;db-1x2.db&quot; )
		;db        		(atom (str (.getRemoteAddress socketClient) &quot;appli\\db-1x2.db&quot;))
		db        		(atom (str serverAdd &quot;\\db-1x2.db&quot;))
 	    read-Db   		(read-bin-file @db )
        label     		(JLabel. &quot;Search: &quot; )
        imagelogo 		(ImageIcon. &quot;Images/logohade.png&quot;)
        imagelegend 	(ImageIcon. &quot;Images/leyenda.png&quot;)
        imagelegend2	(ImageIcon. &quot;Images/leyenda2.png&quot;)
        logo        	(JLabel. imagelogo) 
        legend     		(JLabel. imagelegend) 
        legend2     	(JLabel. imagelegend2) 
        txtSearch 		(JTextField. 30 )
        combobox  		(JComboBox. )
        panelTop  		(JPanel. )
        panelRight 		(JPanel. )
        panelBottom 	(JPanel. )
        flowlayout 		(new FlowLayout )
        gridLayout 		(GridLayout. 10 0 5 5)
        btnFind			(JButton. &quot;Find&quot;)
	    btnAdd 			(JButton. &quot;Add&quot;)
		btnDelete		(JButton. &quot;Delete&quot;)
		btnRefresh 		(JButton. &quot;Refresh&quot;)
		get-column-change        (atom -1)
        get-row-change           (atom -1)
        get-value-at-change      (atom &quot; &quot;)
		get-pos                  (atom -1) 
		get-record-value         (atom &quot; &quot;) 
		recordsVector     (get-records-vector read-Db)
        recordsMap       (get-records-map (filter-records recordsVector) )    
        model  	(fill-JTable recordsMap read-Db)
	    table (JTable. model)
	    defaultModel (DefaultTableModel.)
	    table2 (JTable. defaultModel) 
        scrollTable (JScrollPane. table2)
	    number-records ( count-records recordsVector)
	       
  ;------------Method search---------------------------------------------------------------------
		handlerBtnFind  (proxy [ActionListener][]
			(actionPerformed [event]
	        
				(if (= {:records []} (convertToMap (filter-records-search(.getText txtSearch) recordsVector (.getSelectedItem combobox)))) (JOptionPane/showMessageDialog frame (str &quot;-&quot; (.getText txtSearch) &quot;-&quot; &quot; not found searching by &quot; (.getSelectedItem combobox)) &quot;No results found&quot; JOptionPane/INFORMATION_MESSAGE)
				(windowSearchResult &quot;Search Result&quot; read-Db  (convertToMap (filter-records-search(.getText txtSearch) recordsVector (.getSelectedItem combobox))) )
				)
			)
		)
	;--------------Handler button Add row-------------------------------------------------------				
		handlerBtnAdd  (proxy [ActionListener][]
			(actionPerformed [event]
				(.addRow defaultModel (to-array []))
				(write-empty-row &quot;db-1x2.db&quot; (count-records (get-records-vector (read-bin-file &quot;db-1x2.db&quot;))))
				
				 (.setVisible frame true) 						
				 (.dispose frame) 				  
				 (windowClient &quot;Hades Booking System&quot; socketClient input output serverAdd)
			)
		)
	;--------------Handler button Deleted--------------------------------------------------------			
	handlerBtnDelete (proxy [ActionListener][]
		(actionPerformed [event]
			(let [initialNumber  (.getSelectedRow table2)
				  record	       (get-record-table (.getSelectedRow table2) table2)  
				  pos            (atom -1) 
					]
			     (get-position-in-Db (count-records recordsVector)  recordsVector record pos)
					      (if (= (&gt; @pos -1) true) 		(erase-record &quot;db-1x2.db&quot; @pos) 		) 
			       
					  (dorun (for [i (range (.getSelectedRow table2)(+ (.getSelectedRow table2) (count (.getSelectedRows table2))))]
						          (.removeRow defaultModel initialNumber)
					   ))
					   
							 		 (.setVisible frame true) 						
										(.dispose frame) 				  
										(windowClient &quot;Hades Booking System&quot; socketClient input output serverAdd)
				   
			)	
		)
	)

	handlerRefresh( proxy [ActionListener] []  
		(actionPerformed [event]
			(.setVisible frame true) 						
			(.dispose frame) 				  
			(windowClient &quot;Hades Booking System&quot; socketClient input output serverAdd)
		)
	)		
]
	
	;------------------ Method to fill manually the table ----------------
 	(fill-JTable-DefaultModel table defaultModel get-row-change get-column-change get-value-at-change)
	;---------------------------------------------------------------------
	
	;************************ Create the interface Java***********************************

	
   ;-----------------------PanelTop-------------------------------------
	  (.setIconImage frame (.getImage (ImageIcon. &quot;Images/IconoHades.png&quot;)))
    (.setDefaultCloseOperation frame JFrame/EXIT_ON_CLOSE)
    (.setBackground panelTop (Color. 135 206 235))
    (.setLayout panelTop flowlayout)
    (.setAlignment flowlayout FlowLayout/TRAILING)
    (.add panelTop combobox)
    (.add panelTop txtSearch)
    (.add panelTop label)
    (.addItem combobox &quot;name&quot;)
    (.addItem combobox  &quot;location&quot;)
    (.add panelTop logo)
    (.setComponentOrientation panelTop  ComponentOrientation/RIGHT_TO_LEFT)
    (.add frame panelTop  BorderLayout/NORTH )
    
   ;----------------AddActionListener to the buttons in the frame-----------------------------------
    (.addActionListener btnFind handlerBtnFind)
	(.addActionListener btnAdd handlerBtnAdd)
	(.addActionListener btnDelete handlerBtnDelete)
	(.addActionListener btnRefresh handlerRefresh) 
    (.setPreferredSize panelRight (Dimension. 160 60))
    (.setLayout panelRight gridLayout)
    (.setBackground panelRight (Color. 135 206 235))
         
    (.add panelRight btnFind )
    (.add panelRight btnAdd)
    (.add panelRight btnDelete)
    (.add panelRight btnAdd)
    (.add panelRight btnRefresh)
    (.add panelRight legend)
    (.add panelRight legend2) 
    (.add frame panelRight  BorderLayout/EAST)
     
		
    (.add frame scrollTable)
 
  ;--------------Add Listeners table -------------------------------------
        
  (.addKeyListener table2 
    (proxy [KeyAdapter] []
    
				(keyReleased [event]
					
		     (if (and (not= @get-row-change -1) (not= get-column-change -1) (= (.isEditing table2) true))
			            (reset! get-record-value (get-record-table (.getSelectedRow table2) table2)))
			
			(if (and (not= @get-row-change -1) (not= @get-column-change -1))
			   (reset! get-value-at-change  (.getValueAt table @get-row-change @get-column-change))
			)
         																			   
					(if (and (not= @get-value-at-change -1) (not=  @get-row-change -1) (=(.isEditing table2) false)
					(or (= (.getKeyCode event) VK_ENTER) (= (.getKeyCode event) VK_LEFT) (= (.getKeyCode event) VK_RIGHT)
					    (= (.getKeyCode event) VK_UP) (= (.getKeyCode event) VK_DOWN)))
					
					(let [
							name	(str (.getValueAt table2 @get-row-change 0))
					 		location (str (.getValueAt table2 @get-row-change 1))
					 		size     (str (.getValueAt table2 @get-row-change 2))
					 		smoking  (str (.getValueAt table2 @get-row-change 3))
					 		rate     (str (.getValueAt table2 @get-row-change 4))
					 		date     (str (.getValueAt table2 @get-row-change 5))
					 		owner    (str (.getValueAt table2 @get-row-change 6))
							elementsToWrite		(str @get-pos &quot;#&quot; name &quot;#&quot; location &quot;#&quot; size &quot;#&quot; smoking &quot;#&quot; rate &quot;#&quot; date &quot;#&quot; owner)
							
						]
					
							(get-position-in-Db (count-records recordsVector) recordsVector @get-record-value get-pos)
							(if (&gt; @get-pos -1)
								(if (not= owner &quot;&quot;)
									(.writeUTF output (String. elementsToWrite))
									(.writeUTF output (str @get-pos &quot;#&quot; name &quot;#&quot; location &quot;#&quot; size &quot;#&quot; smoking &quot;#&quot; rate &quot;#&quot; date &quot;#&quot; &quot; &quot;))
								)
							)
							
							(.flush output)
							(.repaint table2)
					 )
					  (reset! get-value-at-change -1)
					) 					    
			)
			 (keyTyped [event]
		  		(if (not= (.getEditingRow table2) -1)     (reset!   get-row-change (.getEditingRow table2))) 
			    (if (not= (.getEditingColumn table2) -1)  (reset!   get-column-change (.getEditingColumn table2)) )					
		 	 )
		 ) 
	)
	
	 (.addMouseListener table2 
	  (proxy [MouseListener] [] 
				(mouseClicked [event]) 
				(mouseEntered [event]) 
				(mouseExited  [event]) 
				(mousePressed  [event] 
				  
				(if (not= (.getEditingRow table2) -1)  (reset!   get-row-change (.getEditingRow table2))) 
			    (if (not= (.getEditingColumn table2) -1)  (reset!   get-column-change (.getEditingColumn table2)) )	
			    
			    (if (and (not= @get-row-change -1) (not= @get-column-change -1))  					 
					   (reset! get-record-value (get-record-table (.getSelectedRow table2) table2) ))
	    	) 
		    (mouseReleased [event])
		 ) 
	)
	
	 (change-Foreground-table table2)
	 
	 ;--------Frame----------------------------------------------------------
	 
    (.pack frame)
    (.setSize frame (Dimension. 900 500))
    (.setVisible frame true))
    ;---------------------------------------------------------------------
    
    
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-appli.hadesWindow-windowSearchResult"/><dl class="library-member-table"><dt class="library-member-name">windowSearchResult</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([title read-Db searchMap])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Displays the new Window with the result of a search. Receives three parameters: title name of the window, the data base lecture,  the map of what the user is looking for. </div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-appli.hadesWindow-windowSearchResult&apos;)" id="linkto-membersource-appli.hadesWindow-windowSearchResult">Show Source</a> ]</div><div class="library-member-source" id="membersource-appli.hadesWindow-windowSearchResult"><pre>(defn windowSearchResult
   &quot;Displays the new Window with the result of a search. Receives three parameters: title name of the window, the data base lecture,  the map of what the user is looking for. &quot;
  [title  read-Db searchMap ]
  (let [frame     	(JFrame. title)
        panelRight 	(JPanel. )
        flowlayout 	(new FlowLayout )
        gridLayout 	(GridLayout. 10 0 5 5)
        btnClose	(JButton. &quot;Close&quot;)
		    btnDelete	(JButton. &quot;Delete&quot;)
	    	frameImage 	(Frame.)
	    	model  		(fill-JTable searchMap read-Db)
		    table (proxy [JTable] [model]
		            (isCellEditable  [row col] false)
		          )
        scrollTable (JScrollPane. table)
        
        
        get-column-change        (atom -1)
        get-row-change           (atom -1)
        get-value-at-change      (atom &quot; &quot;) 
		
		handler-jframe  (proxy [ActionListener][]
			(actionPerformed [event]
				(.setVisible frame true)
				(.dispose frame)
			)
		)
		defaultModel (DefaultTableModel.)
   ]
	
	;------------------ Method to fill manually the table ----------------
		(fill-JTable-DefaultModel table defaultModel get-row-change get-column-change get-value-at-change)
	;---------------------------------------------------------------------
        
	(.setDefaultCloseOperation frame JFrame/HIDE_ON_CLOSE)
	(.setIconImage frame (.getImage (ImageIcon. &quot;IconoHades.png&quot;)))
    (.setAlignment flowlayout FlowLayout/TRAILING)
	(.setPreferredSize btnClose (Dimension. 28 75))
    (.setPreferredSize panelRight (Dimension. 130 20))
    (.setLayout panelRight gridLayout)
    (.setBackground panelRight (Color. 135 206 235))
	
	  
	(.addActionListener btnClose handler-jframe) 
 	(.add panelRight btnClose)
    (.add frame panelRight  BorderLayout/EAST)
  	(.add frame scrollTable)
	(.addMouseListener table 
		(proxy [MouseListener] [] 
			(mouseClicked [event] 
			(JOptionPane/showMessageDialog frame &quot;Please make your changes on the main window.&quot;)) 
			(mouseEntered [event]) 
			(mouseExited  [event]) 
			(mousePressed  [event]) 
		    (mouseReleased [event])
		     ) 
		)
	(change-Foreground-table table)
    (.pack frame)
    (.setSize frame (Dimension. 800 270))
    (.setVisible frame true))
)</pre></div></div></dd></dl></li></ol></div></div></body></html>